<template>
  <div id="sign-home">
    <c-title :text="shop_name"></c-title>
    <div class="search-box">
      <ul class="search">
        <li class="left" @click="routerGo">
          <i class="iconfont icon-zx_map_locate2"></i>
          <span>{{ address.title || "请选择" }}</span>
          <i class="iconfont icon-icon_more11"></i>
        </li>
        <li class="right" v-show="address.title" @click="goSearchPage">
          <i class="iconfont icon-a-icon_pressed"></i>
          <input type="text" title="搜索" placeholder="搜索商品" readonly="readonly"/>
        </li>
      </ul>
    </div>
    <div class="content-row" v-show="address.title">
      <van-swipe indicator-color="#F15353" class="my-swipe"  v-if="banner.length"  :autoplay="3000">
        <van-swipe-item v-for="(item,index) in banner" :key="index">
          <img :src="item.image" @click="goPage(item.web_url)"/>
        </van-swipe-item>
      </van-swipe>

      <van-swipe class="my-swipe" indicator-color="#F15353" v-if="button.length">
        <van-swipe-item v-for="(item, index) in button" :key="index">
          <div class="publisher-detail">
            <div class="publisher-box" v-for="(citem, cindex) in item" @click="goPage(citem.web_url)" :key="cindex">
              <img :src="citem.image" alt="" />
              <span class="name">{{ citem.title }}</span>
            </div>
          </div>
        </van-swipe-item>
      </van-swipe>

      <van-swipe indicator-color="#F15353" class="my-swipe" v-if="activity.length" :autoplay="3000">
        <van-swipe-item v-for="(item,index) in activity" :key="index">
          <img :src="item.image" @click="goPage(item.web_url)"/>
        </van-swipe-item>
      </van-swipe>
      <div class="local-box" v-if="agent">
        <div class="top-tip">
          <span :class="type_val == 1 ? 'active-tip-color tip-sty' : 'tip-sty'" @click="clickType(1,'type_val')">本地商城<span class="active-tip-sty" v-if="type_val == 1"></span></span>
          <span v-if="config.local_shop_page" :class="type_val == 2 ? 'active-tip-color tip-sty' : 'tip-sty'" @click="clickType(2,'type_val')">本地店铺<span class="active-tip-sty" v-if="type_val == 2"></span></span>
        </div>
        <div class="local-mall" v-show="type_val == 1">
          <div class="local-classify">
            <span :class="category_id == item.id ? 'active-normal-style normal-style' : 'normal-style'" v-for="(item, index) in goods_category" :key="index" @click="clickType(item.id,'category_id')">{{
              item.name
            }}</span>
          </div>
          <d-list :loading="loading" :finished="finished" @load="onLoad">
            <div class="mall-detail">
              <div class="mall-box" v-for="(item,index) in goodsList" :key="index" @click="goGoodsDetail(item.id)">
                <img :src="item.thumb" alt="" />
                <div>
                  <div class="title">{{item.title}}</div>
                  <div class="price">¥{{item.price}}</div>
                </div>
              </div>
            </div>
          </d-list>
        </div>
        <div class="local-shop" v-show="type_val == 2">
          <d-list :loading="loading" :finished="finished" @load="onLoad">
            <div class="shop-row" v-for="(item,index) in goodsList" :key="index">
              <div class="top-rol">
                <div class="left-detail">
                  <img :src="item.logo" alt="" />
                  <div class="detail-wap">
                    <div class="shop-name">{{item.store_name}}</div>
                    <div class="shop-num">在售商品：{{item.goods_total}}</div>
                  </div>
                </div>
                <span class="go-shop" @click="goEnterShop(item.id)">进店</span>
              </div>
              <div class="bottom-rol">
                <div class="goods-box" v-for="citem in item.goods_list" :key="citem.id" @click="goGoodsDetail(citem.id)">
                  <img :src="citem.thumb" alt="" />
                  <div class="goods-title">{{citem.title}}</div>
                  <div class="goods-price">
                    <span class="symbol">￥</span>
                    <span class="price-val">{{citem.price}}</span>
                  </div>
                </div>
              </div>
            </div>
          </d-list>
        </div>
      </div>
      <div v-if="!agent && !banner.length && !button.length && !activity.length" class="no-content">暂无内容</div>
    </div>
    <div class="location-icon" v-if="!address.title">
      <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/shop_locate.png" alt="" />
      <div>请先选择定位</div>
    </div>
  </div>
</template>
<script>
import sign_home_controller from "./sign_home_controller";

export default sign_home_controller;
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
::v-deep .van-swipe__indicators {
  bottom: 8px;
}

.search-box {
  .search {
    height: 3.2rem;
    line-height: 3.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.8rem;
    background-color: #fff;

    .text {
      font-size: 14px;
      color: #1c96fe;
    }

    .left {
      font-size: 15px;
      display: flex;

      i {
        color: #333333;
        font-size: 0.75rem;
        // font-weight: 700;
      }

      span {
        display: block;
        max-width: 5.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.75rem;
        font-weight: 500;
        color: #333333;
        margin-right: 0.2rem;
        line-height: 3.2rem;
      }

      // i:last-child {
      //   font-size: 1.125rem;
      // }
    }

    .right {
      width: 65%;
      height: 2rem;
      background: #f5f5f5;
      display: flex;
      line-height: 2rem;
      border-radius: 1rem;
      padding: 0 0.625rem 0 0;
      font-size: 14px;

      i {
        font-size: 1.1rem;
        color: #999;
        margin: 0 0.2rem 0 0.6rem;
      }

      input {
        border: none;
        width: 100%;
      }
    }
  }
}

.content-row {
  padding: 0.8rem;
  .van-swipe-item {
    height: initial;
  }
  .my-swipe {
    background: white;
    margin-bottom: 0.7rem;
    border-radius: 0.4rem;
    img {
      width: 100%;
      border-radius: 0.5rem;
      height: 100%;
    }
  }

  .publisher-detail {
    display: flex;
    flex-wrap: wrap;
    padding: 0.4rem 0.5rem;
    background: white;
    border-radius: 0.4rem;
    // height: 9.83rem;
    padding-bottom: 1.2rem;

    .publisher-box {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-top: 0.8rem;
      width: 20%;

      img {
        width: 3.2rem;
        height: 3.2rem;
        background: #e8e8e8;
        border-radius: 0.1rem 0.1rem 0.1rem 0.1rem;
        opacity: 1;
        margin: 0;
        border-radius: 50%;
      }

      .name {
        font-size: 0.8rem;
        font-weight: 400;
        color: #3b3b4a;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        word-break: break-all;
        overflow: hidden;
        margin-top: 0.4rem;
      }
    }
  }

  .local-box {
    .top-tip {
      display: flex;
      margin-left: 0.25rem;
      .tip-sty {
        font-size: 0.85rem;
        margin-right: 0.83rem;
        font-weight: 500;
        color: #3b3b4a;
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      .active-tip-color {
        font-size: 0.9rem;
        font-weight: bold;
        color: #00001c;
      }
      .active-tip-sty {
        width: 1rem;
        display: block;
        border-radius: 1rem;
        height: 0.15rem;
        background: #f15353;
        margin-top: 0.1rem;
      }
    }
    .local-mall {
      .local-classify {
        display: flex;
        overflow-y: scroll;
        margin-top: 0.85rem;
        .normal-style {
          font-size: 0.75rem;
          font-weight: 400;
          color: #3b3b4a;
          background: #ffffff;
          border-radius: 0.4rem;
          padding: 0.3rem 0.7rem;
          margin-right: 0.7rem;
          white-space: nowrap;
        }
        .active-normal-style {
          background: rgba(241, 83, 83, 0.1);
          border: 1px solid #f15353;
          color: #f15353;
        }
      }
      .mall-detail {
        margin-top: 1rem;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-gap: 0.8rem;
        .mall-box {
          border-radius: 0.8rem;
          text-align: left;
          background: white;
          .title {
            font-size: 0.8rem;
            font-weight: bold;
            color: #00001c;
            line-height: 0.9rem;
            margin: 0.1rem 0.85rem 0 0.8rem;
            overflow: hidden;
            text-overflow: ellipsis;
            -webkit-line-clamp: 2;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            // height: 2.2rem;
            line-height: 1.3;
          }
          .price {
            font-size: 0.9rem;
            font-weight: bold;
            color: #f15353;
            margin: 0 0.85rem 0.5rem 0.8rem;
          }
          img {
            height: 10.5rem;
            background: #c1c1c1;
            border-radius: 0.8rem 0.8rem 0px 0px;
            margin: 0;
            width: 100%;
          }
        }
      }
    }
    .local-shop {
      margin-top: 0.75rem;
      .shop-row {
        background: white;
        padding: 0.8rem;
        border-radius: 0.4rem;
        margin-bottom: 0.8rem;
        .top-rol {
          display: flex;
          align-items: center;
          justify-content: space-between;
          .left-detail {
            display: flex;
            img {
              width: 3rem;
              height: 3rem;
              border-radius: 0.4rem;
              margin: 0 0.4rem 0 0;
            }
            .detail-wap {
              display: flex;
              flex-direction: column;
              text-align: left;
              justify-content: space-between;
              .shop-name {
                font-size: 0.85rem;
                font-weight: bold;
                color: #00001c;
                overflow: hidden;
                text-overflow: ellipsis;
                -webkit-line-clamp: 1;
                display: -webkit-box;
                -webkit-box-orient: vertical;
              }
              .shop-num {
                font-size: 0.75rem;
                font-weight: 400;
                color: #6e6e79;
              }
            }
          }
          .go-shop {
            background: #f15353;
            border-radius: 1.5rem;
            padding: 0.4rem 1.1rem;
            color: white;
          }
        }
        .bottom-rol {
          // display: flex;
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          grid-gap: 0.8rem;
          .goods-box {
            margin-top: 0.7rem;
            width: 100%;
            text-align: left;
            .goods-title {
              font-size: 0.8rem;
              font-weight: 500;
              color: #00001c;
              overflow: hidden;
              text-overflow: ellipsis;
              -webkit-line-clamp: 1;
              display: -webkit-box;
              -webkit-box-orient: vertical;
              margin: 0.1rem 0;
            }
            img {
              margin: 0;
              height: 6rem;
              width: 100%;
              border-radius: 0.4rem;
            }
            .goods-price {
              font-size: 0.75rem;
              font-weight: bold;
              color: #f15353;
              .symbol {
                zoom: 0.8;
              }
            }
          }
        }
      }
    }
  }
}

.location-icon {
  margin-top: 5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #333333;
  img {
    width: 8rem;
    height: 8rem;
  }
}

.no-content {
  text-align: center;
  color: #7f7f7f;
}
</style>
